*******************************************************************************
* Survey Mode Effects in a Developing Country: Comparing Phone and Face-to-Face Surveys in Costa Rica"
* By Noam Lupu and Adam D. Wolsky
* This do file replicates the results the main paper and appendix
*******************************************************************************

clear
set more off

use "ciep_lapop_merge.dta",clear

ssc install estout, replace
ssc install coefplot, replace
ssc install cem, replace

lab lang en

* Standardizing Education

gen educ = 1 if educarec == 1 | ed >= 0 & ed <= 6
replace educ = 2 if educarec == 2 | ed >= 7 & ed <= 12
replace educ = 3 if educarec == 3 | ed >= 13 & ed <= 18

lab var educ "Education"
lab define educ 1 "Primary" 2 "Secondary" 3 "University"

gen college = 1 if educ == 3
replace college = 0 if educ == 1 | educ == 2

lab var college "College"
lab define college 0 "Primary or Secondary" 1 "University"
lab val college college

* Age Cohorts

replace age1 = (q2 > 17 & q2 < 26)
replace age2 = (q2 > 25 & q2 < 36)
replace age3 = (q2 > 35 & q2 < 46)
replace age4 = (q2 > 45 & q2 < 56)
replace age5 = (q2 > 55 & q2 < 66)
replace age6 = (q2 > 65)

replace edad = 1 if age1 == 1
replace edad = 2 if age2 == 1
replace edad = 3 if age3 == 1
replace edad = 4 if age4 == 1
replace edad = 5 if age5 == 1
replace edad = 6 if age6 == 1

lab var age1 "18-25 Dummy"
lab var age2 "26-35 Dummy"
lab var age3 "36-45 Dummy"
lab var age4 "46-55 Dummy"
lab var age5 "56-65 Dummy"
lab var age6 "66+ Dummy"

lab var edad "Age groups"
lab define edad 1 "18-25" 2 "26-35" 3 "36-45" 4 "46-55" 5 "56-65" 6 "66+",replace
lab val edad edad

* Gender

gen female = 1 if q1 == 2
replace female = 0 if q1 == 1

lab var female "Female Respondent Dummy"
lab define female 0 "Male" 1 "Female"
lab val female female

* Recoding Substantive Variables

replace cosvb2a = . if cosvb2a == 99
replace eff2 = . if eff2 == 99
replace d6 = . if d6 == 99
replace ros4 = . if ros4 == 99

gen turnout1 = .
replace turnout1 = 1 if vb2 == 1
replace turnout1 = 0 if vb2 == 2
lab var turnout1 "Voted in Last Election (1st Round)"
lab define turnout 1 "Voted" 0 "Did not vote"
lab val turnout1 turnout

gen turnout2 = .
replace turnout2 = 1 if cosvb2a == 1
replace turnout2 = 0 if cosvb2a == 2
lab var turnout2 "Voted in Last Election (2nd Round)"
lab val turnout2 turnout

recode w14a (2 = 0) (99 = .), gen(abjustified)
lab var abjustified "Abortion when mother's health at risk"
lab define abjustified 1 "Yes, it is justified" 0 "No, it is not justified"
lab val abjustified abjustified

recode vb3n (0 97 602/677 = 0) (601 = 1), gen(calvarado_r1)
lab var calvarado_r1 "C. Alvarado Vote (R1)"

recode cosvb3a (0 98 602 = 0) (601 = 1), gen(calvarado_r2)
lab var calvarado_r2 "C. Alvarado Vote (R2)"

recode sexi (1 = 0) (2 = 1) (99 = .), gen(femint)
lab var femint "Female Interviewer"
lab def femint 0 "Male" 1 "Female"
lab val femint femint

* Creating Province Dummies

tabulate prov, generate(dprov)

lab var dprov1 "San José dummy"
lab var dprov2 "Alajuela dummy"
lab var dprov3 "Cartago dummy"
lab var dprov4 "Heredia dummy"
lab var dprov5 "Guanacaste dummy"
lab var dprov6 "Puntarenas dummy"
lab var dprov7  "Limón dummy"

tabulate educ, generate(educ)
lab var educ1 "Primary dummy"
lab var educ2 "Secondary dummy"
lab var educ3 "University dummy"

* Rescaling variables

sum eff2
gen eff2_r = (eff2 - `r(min)') / (`r(max)'-`r(min)')

sum ros4
gen ros4_r = (ros4 - `r(min)') / (`r(max)'-`r(min)')

sum d6
gen d6_r = (d6 - `r(min)') / (`r(max)'-`r(min)')

lab var eff2_r "Understands Important Political Issues (Recoded)"
lab var ros4_r "Government Should Implement Policies to Reduce Income Inequality (Recoded)"
lab var d6_r "Approval of Same-Sex Couples' Right to Marry (Recoded)"

keep female age1 age2 age3 age4 age5 age6 educ1 educ2 educ3 r4 r15 r18 dprov1 dprov2 dprov3 dprov4 dprov5 dprov6 dprov7 educ edad college femint eff2 ros4 d6 eff2_r ros4_r d6_r turnout1 turnout2 calvarado_r1 calvarado_r2 abjustified ciep
 
* Let's delete all code above and just have the tables/analysis

* Comparing survey samples (Table A1)

prtest female, by(ciep)

prtest age1, by(ciep)
prtest age2, by(ciep)
prtest age3, by(ciep)
prtest age4, by(ciep)
prtest age5, by(ciep)
prtest age6, by(ciep)

prtest educ1, by(ciep)
prtest educ2, by(ciep)
prtest educ3, by(ciep)

prtest r4, by(ciep)
prtest r15, by(ciep)
prtest r18, by(ciep)

prtest dprov1, by(ciep)
prtest dprov2, by(ciep)
prtest dprov3, by(ciep)
prtest dprov4, by(ciep)
prtest dprov5, by(ciep)
prtest dprov6, by(ciep)
prtest dprov7, by(ciep)


* Calculating imbalance prior to CEM weights

imb educ edad college female r4 r15 r18 dprov1 dprov6 femint, treatment(ciep)


* Creating CEM weights / getting L1 distance statistic

cem educ (1 2 3) edad (1 2 3 4 5 6) female r4 r15 r18 dprov1 dprov6 femint, treatment(ciep)  


* Getting proportions of key demographic variables before and after CEM weights applied (Table A2)

foreach x in college age6 female r4 r15 r18 dprov1 dprov6 femint {
	prop `x', over(ciep)
	matrix `x' = r(table)
	matrix `x' = `x'[1...,3], `x'[1...,4]
	matrix colnames `x' = :LAPOP :CIEP
	matrix rownames `x' = `x' se
	prop `x' [iweight  = cem_weights], over(ciep)
	matrix `x'cem = r(table)
	matrix `x'cem = `x'cem[1...,3], `x'cem[1...,4]
	matrix colnames `x'cem = ":LAPOP cem wts" ":CIEPcem cem wts"
	matrix rownames `x' = `x' se
	matrix `x' = `x',`x'cem
	matrix `x' = `x'[1..2,1...]
}

* Extracting each proprtion value and standard error from matrix

matrix lapop1 = college[1,1],age6[1,1],female[1,1],r4[1,1], ///
r15[1,1],r18[1,1],dprov1[1,1],dprov6[1,1],femint[1,1]

matrix selapop1 = college[2,1],age6[2,1],female[2,1],r4[2,1], ///
r15[2,1],r18[2,1],dprov1[2,1],dprov6[2,1],femint[2,1]

matrix ciep1 = college[1,2],age6[1,2],female[1,2],r4[1,2], ///
r15[1,2],r18[1,2],dprov1[1,2],dprov6[1,2],femint[1,2]

matrix seciep1 = college[2,2],age6[2,2],female[2,2],r4[2,2], ///
r15[2,2],r18[2,2],dprov1[2,2],dprov6[2,2],femint[2,2]

matrix lapop2 = college[1,3],age6[1,3],female[1,3],r4[1,3], ///
r15[1,3],r18[1,3],dprov1[1,3],dprov6[1,3],femint[1,3]

matrix selapop2 = college[2,3],age6[2,3],female[2,3],r4[2,3], ///
r15[2,3],r18[2,3],dprov1[2,3],dprov6[2,3],femint[2,3]

matrix ciep2 = college[1,4],age6[1,4],female[1,4],r4[1,4], ///
r15[1,4],r18[1,4],dprov1[1,4],dprov6[1,4],femint[1,4]

matrix seciep2 = college[2,4],age6[2,4],female[2,4],r4[2,4], ///
r15[2,4],r18[2,4],dprov1[2,4],dprov6[2,4],femint[2,4]

* Adding the values of the proportions and standard errors

estadd matrix lapop1
estadd matrix selapop1
estadd matrix ciep1
estadd matrix seciep1
estadd matrix lapop2
estadd matrix selapop2
estadd matrix ciep2
estadd matrix seciep2

esttab using costaricadescriptives.rtf, ///
cells("lapop1(fmt(2)) ciep1 lapop2 ciep2" "selapop1(par) seciep1(par) selapop2(par) seciep2(par)") ///
collabels("LAPOP" "CIEP" "LAPOP CEM" "CIEP CEM") coeflabels (c1 "College" c2 "65+" c3 "Female" ///
c4 "Landline" c5 "Computer" c6 "Internet" c7 "San Jose" c8 "Puntarenas" c9 "Int Sex") noobs ///
addnotes(Note: Standard errors in parentheses.) nomtitles nonumbers replace
eststo clear 


* Comparing substantive responses across modes (Figure 1 and Table A3)

mean eff2_r [iweight = cem_weights], over(ciep)
lincom _b[c.eff2_r@0.ciep] - _b[c.eff2_r@1.ciep]
matrix eff2_1 = r(estimate)
matrix eff2_2 = r(lb)
matrix eff2_3 = r(ub)

matrix eff2_r = (eff2_1, eff2_2, eff2_3)'

mean ros4_r [iweight = cem_weights], over(ciep)
lincom _b[c.ros4_r@0.ciep] - _b[c.ros4_r@1.ciep]
matrix ros4_1 = r(estimate)
matrix ros4_2 = r(lb)
matrix ros4_3 = r(ub)

matrix ros4_r = (ros4_1, ros4_2, ros4_3)'

prop abjustified [iweight = cem_weights], over(ciep)
lincom [1.abjustified@0.ciep] - [1.abjustified@1.ciep]
matrix abjustified_1 = r(estimate)
matrix abjustified_2 = r(lb)
matrix abjustified_3 = r(ub)

matrix abjustified_r = (abjustified_1, abjustified_2, abjustified_3)'

mean d6_r [iweight = cem_weights], over(ciep)
lincom _b[c.d6_r@0.ciep] - _b[c.d6_r@1.ciep]
matrix d6_1 = r(estimate)
matrix d6_2 = r(lb)
matrix d6_3 = r(ub)

matrix d6_r = (d6_1, d6_2, d6_3)'

prop turnout1 [iweight = cem_weights], over(ciep)
lincom [1.turnout1@0.ciep] - [1.turnout1@1.ciep]
matrix turnout1_1 = r(estimate)
matrix turnout1_2 = r(lb)
matrix turnout1_3 = r(ub)

matrix turnout1 = (turnout1_1, turnout1_2, turnout1_3)'

prop turnout2 [iweight = cem_weights], over(ciep)
lincom [1.turnout2@0.ciep] - [1.turnout2@1.ciep]
matrix turnout2_1 = r(estimate)
matrix turnout2_2 = r(lb)
matrix turnout2_3 = r(ub)

matrix turnout2 = (turnout2_1, turnout2_2, turnout2_3)'

prop calvarado_r1 [iweight = cem_weights], over(ciep)
lincom  [1.calvarado_r1@0.ciep] - [1.calvarado_r1@1.ciep]
matrix calvarado_r1_1 = r(estimate)
matrix calvarado_r1_2 = r(lb)
matrix calvarado_r1_3 = r(ub)

matrix calvarado_r1 = (calvarado_r1_1, calvarado_r1_2, calvarado_r1_3)'

prop calvarado_r2 [iweight = cem_weights], over(ciep)
lincom [1.calvarado_r2@0.ciep] - [1.calvarado_r2@1.ciep]
matrix calvarado_r2_1 = r(estimate)
matrix calvarado_r2_2 = r(lb)
matrix calvarado_r2_3 = r(ub)

matrix calvarado_r2 = (calvarado_r2_1, calvarado_r2_2, calvarado_r2_3)'

matrix socdesir = eff2_r,ros4_r,abjustified_r,d6_r,turnout1,turnout2,calvarado_r1,calvarado_r2
matrix colnames socdesir = 1 2 3 4 5 6 7 8

matrix list socdesir

coefplot (matrix(socdesir[1,]), ci((socdesir[2,] socdesir[3,])) msymbol(O) mlcolor(black) mfcolor(white) if(@ll<0 & @ul>0)) ///
(matrix(socdesir[1,]), ci((socdesir[2,] socdesir[3,])) msymbol(O) mcolor(black) if(@ll>0 | @ul<0)), ///
ciopts(lcolor(black)) nooffset xline(0, lcolor(black) lpattern(dot) lwidth(vthin)) ///
ylabel(1 "Internal efficacy" 2 "Inequality" 3 "Abortion" 4 "Same-sex marriage" ///
5 "Turnout (R1)" 6 "Turnout (R2)"  7 "C. Alvarado vote (R1)" 8 "C. Alvarado vote (R2)", ///
labsize(small)) legend(off) xlabel(-.15(.05).15) ///
xtitle(" " "Difference") legend(off)  graphregion(color(white))
graph export socdesirability.eps, as(eps) replace

* Comparing endpoint responses across modes (Figure 2 and Table A4)

prop eff2 [iweight  = cem_weights], over(ciep)
lincom [1.eff2@0.ciep] - [1.eff2@1.ciep]
matrix eff2min_1 = r(estimate)
matrix eff2min_2 = r(lb)
matrix eff2min_3 = r(ub)

matrix eff2min = (eff2min_1, eff2min_2, eff2min_3)'

prop eff2 [iweight  = cem_weights], over(ciep)
lincom [7.eff2@0.ciep] - [7.eff2@1.ciep]
matrix eff2max_1 = r(estimate)
matrix eff2max_2 = r(lb)
matrix eff2max_3 = r(ub)

matrix eff2max = (eff2max_1, eff2max_2, eff2max_3)'

prop ros4 [iweight  = cem_weights], over(ciep)
lincom [1.ros4@0.ciep] - [1.ros4@1.ciep]
matrix ros4min_1 = r(estimate)
matrix ros4min_2 = r(lb)
matrix ros4min_3 = r(ub)

matrix ros4min = (ros4min_1, ros4min_2, ros4min_3)'

prop ros4 [iweight  = cem_weights], over(ciep)
lincom [7.ros4@0.ciep] - [7.ros4@1.ciep]
matrix ros4max_1 = r(estimate)
matrix ros4max_2 = r(lb)
matrix ros4max_3 = r(ub)

matrix ros4max = (ros4max_1, ros4max_2, ros4max_3)'

prop d6 [iweight  = cem_weights], over(ciep)
lincom [1.d6@0.ciep] - [1.d6@1.ciep]
matrix d6min_1 = r(estimate)
matrix d6min_2 = r(lb)
matrix d6min_3 = r(ub)

matrix d6min = (d6min_1, d6min_2, d6min_3)'

prop d6 [iweight  = cem_weights], over(ciep)
lincom [10.d6@0.ciep] - [10.d6@1.ciep]
matrix d6max_1 = r(estimate)
matrix d6max_2 = r(lb)
matrix d6max_3 = r(ub)

matrix d6max = (d6max_1, d6max_2, d6max_3)'

* Making Big Matrix

matrix endpoints  = eff2min, eff2max, ros4min, ros4max, d6min, d6max
matrix colnames endpoints = 1 2 3 4 5 6

* Creating Figure 2

coefplot (matrix(endpoints[1,]), ci((endpoints[2,] endpoints[3,])) msymbol(O) mlcolor(black) mfcolor(white) if(@ll<0 & @ul>0)) ///
(matrix(endpoints[1,]), ci((endpoints[2,] endpoints[3,])) msymbol(O) mcolor(black) if(@ll>0 | @ul<0)), ///
ciopts(lcolor(black)) nooffset xline(0, lcolor(black) lpattern(dot) lwidth(vthin)) ///
ylabel(1 `""Internal efficacy" "(strongly disagree)""' 2 `""Internal efficacy" "(strongly agree)""' ///
3 `""Inequality" "(strongly disagree)""' 4 `""Inequality" "(strongly agree)""' ///
5 `""Same-sex marriage" "(strongly disapprove)""' ///
6 `""Same-sex marriage" "(strongly approve)""', labsize(small)) ///
legend(off) xtitle(" " "Difference") legend(off)  xlabel(-.2(.05).2)graphregion(color(white))
graph export endpoints.eps, as(eps) replace

* Robustness Checks checks

* One-to-one matching

eststo clear 

/* Setting a seed because one-to-one matching randomly removes respondents to balance the treatment and control groups */

set seed 2018

cem educ (1 2 3) edad (1 2 3 4 5 6) female r4 r15 r18 dprov1 dprov6 femint, treatment(ciep) k2k

/* Recreating Table A3 with one-to-one matching */

mean eff2_r [iweight  = cem_weights], over(ciep)
matrix eff2mean = r(table)
matrix eff2mean = eff2mean[1..2,1], eff2mean[1..2,2]
lincom _b[c.eff2_r@0.ciep] - _b[c.eff2_r@1.ciep]
matrix eff2_r_diffin = [r(estimate),r(se)]'

mean ros4_r [iweight  = cem_weights], over(ciep)
matrix ros4mean = r(table)
matrix ros4mean = ros4mean[1..2,1], ros4mean[1..2,2]
lincom _b[c.ros4_r@0.ciep] - _b[c.ros4_r@1.ciep]
matrix ros4_r_diffin =  [r(estimate),r(se)]'

prop abjustified [iweight  = cem_weights], over(ciep)
matrix abjustifiedmean = r(table)
matrix abjustifiedmean = abjustifiedmean[1..2,3], abjustifiedmean[1..2,4]
lincom [1.abjustified@0.ciep] - [1.abjustified@1.ciep]
matrix abjustified_diffin =  [r(estimate),r(se)]'

mean d6_r [iweight  = cem_weights], over(ciep)
matrix d6mean = r(table)
matrix d6mean = d6mean[1..2,1], d6mean[1..2,2]
lincom _b[c.d6_r@0.ciep] - _b[c.d6_r@1.ciep]
matrix d6_r_diffin =  [r(estimate),r(se)]'

prop turnout1  [iweight  = cem_weights], over(ciep)
matrix turnout1mean = r(table)
matrix turnout1mean = turnout1mean[1..2,3], turnout1mean[1..2,4]
lincom [1.turnout1@0.ciep] - [1.turnout1@1.ciep]
matrix turnout1_diffin = [r(estimate),r(se)]'

prop turnout2  [iweight  = cem_weights], over(ciep)
matrix turnout2mean = r(table)
matrix turnout2mean = turnout2mean[1..2,3], turnout2mean[1..2,4]
lincom [1.turnout2@0.ciep] - [1.turnout2@1.ciep]
matrix turnout2_diffin = [r(estimate),r(se)]'

prop calvarado_r1  [iweight  = cem_weights], over(ciep)
matrix calvarado_r1mean = r(table)
matrix calvarado_r1mean = calvarado_r1mean[1..2,3], calvarado_r1mean[1..2,4]
lincom [1.calvarado_r1@0.ciep] - [1.calvarado_r1@1.ciep]
matrix calvarado_r1_diffin = [r(estimate),r(se)]'

prop calvarado_r2  [iweight  = cem_weights], over(ciep)
matrix calvarado_r2mean = r(table)
matrix calvarado_r2mean = calvarado_r2mean[1..2,3], calvarado_r2mean[1..2,4]
lincom [1.calvarado_r2@0.ciep] - [1.calvarado_r2@1.ciep]
matrix calvarado_r2_diffin = [r(estimate),r(se)]'

matrix lapopmean = eff2mean[1,1],ros4mean[1,1],abjustifiedmean[1,1],d6mean[1,1], ///
turnout1mean[1,1],turnout2mean[1,1],calvarado_r1mean[1,1],calvarado_r2mean[1,1]

matrix selapopmean = eff2mean[2,1],ros4mean[2,1],abjustifiedmean[2,1],d6mean[2,1], ///
turnout1mean[2,1],turnout2mean[2,1],calvarado_r1mean[2,1],calvarado_r2mean[2,1]

matrix ciepmean = eff2mean[1,2],ros4mean[1,2],abjustifiedmean[1,2],d6mean[1,2], ///
turnout1mean[1,2],turnout2mean[1,2],calvarado_r1mean[1,2],calvarado_r2mean[1,2]

matrix seciepmean = eff2mean[2,2],ros4mean[2,2],abjustifiedmean[2,2],d6mean[2,2], ///
turnout1mean[2,2],turnout2mean[2,2],calvarado_r1mean[2,2],calvarado_r2mean[2,2]

matrix meandiff = eff2_r_diffin[1,1],ros4_r_diffin[1,1],abjustified_diffin[1,1],d6_r_diffin[1,1], ///
turnout1_diffin[1,1],turnout2_diffin[1,1],calvarado_r1_diffin[1,1],calvarado_r2_diffin[1,1]

matrix semeandiff = eff2_r_diffin[2,1],ros4_r_diffin[2,1],abjustified_diffin[2,1],d6_r_diffin[2,1], ///
turnout1_diffin[2,1],turnout2_diffin[2,1],calvarado_r1_diffin[2,1],calvarado_r2_diffin[2,1]

/* Adding the values of the proportions and standard errors together to make table */

estadd matrix lapopmean
estadd matrix selapopmean
estadd matrix ciepmean
estadd matrix seciepmean
estadd matrix meandiff
estadd matrix semeandiff

/* Table contains the proportions of variables and puts standard error values below in 
parentheses in table */


* Comparing substantive responses across modes with one-to-one matching (Table A5)

esttab using sodesirabilityappendix.rtf, ///
cells("lapopmean(fmt(3)) ciepmean meandiff" "selapopmean(par) seciepmean(par) semeandiff(par)") ///
collabels("LAPOP" "CIEP" "Difference") coeflabels (c1 "Efficacy" c2 "Inequality" c3 "Abortion" ///
c4 "Same Sex Marriage" c5 "Turnout (R1)" c6 "Turnout (R2)" c7 "Vote Choice (R1)" c8 "Vote Choice (R2)") noobs ///
addnotes(Note: Standard errors in parentheses.) nomtitles nonumbers replace

/* Recreating Table A4 with one-to-one matching */

eststo clear 

prop eff2 [iweight  = cem_weights], over(ciep)
matrix eff2min = r(table)
matrix eff2min = eff2min[1...,1], eff2min[1...,2]
matrix eff2min = eff2min[1..2,1...]
lincom [1.eff2@0.ciep] - [1.eff2@1.ciep]
matrix eff2min_diff = [r(estimate),r(se)]'

prop eff2 [iweight  = cem_weights], over(ciep)
matrix eff2max = r(table)
matrix eff2max = eff2max[1...,13], eff2max[1...,14]
matrix eff2max = eff2max[1..2,1...]
lincom [7.eff2@0.ciep] - [7.eff2@1.ciep]
matrix eff2max_diff = [r(estimate),r(se)]'

prop ros4 [iweight  = cem_weights], over(ciep)
matrix ros4min = r(table)
matrix ros4min = ros4min[1...,1], ros4min[1...,2]
matrix ros4min = ros4min[1..2,1...]
lincom [1.ros4@0.ciep] - [1.ros4@1.ciep]
matrix ros4min_diff = [r(estimate),r(se)]'

prop ros4 [iweight  = cem_weights], over(ciep)
matrix ros4max = r(table)
matrix ros4max = ros4max[1...,13], ros4max[1...,14]
matrix ros4max = ros4max[1..2,1...]
lincom [7.ros4@0.ciep] - [7.ros4@1.ciep]
matrix ros4max_diff = [r(estimate),r(se)]'

prop d6 [iweight  = cem_weights], over(ciep)
matrix d6min = r(table)
matrix d6min = d6min[1...,1], d6min[1...,2]
matrix d6min = d6min[1..2,1...]
lincom [1.d6@0.ciep] - [1.d6@1.ciep]
matrix d6min_diff = [r(estimate),r(se)]'

prop d6 [iweight  = cem_weights], over(ciep)
matrix d6max = r(table)
matrix d6max = d6max[1...,19], d6max[1...,20]
matrix d6max = d6max[1..2,1...]
lincom [10.d6@0.ciep] - [10.d6@1.ciep]
matrix d6max_diff = [r(estimate),r(se)]'

/* Extracting each proprtion value and standard error from matrix to format table nicely */

matrix lapopminmax = eff2min[1,1],eff2max[1,1],ros4min[1,1],ros4max[1,1], ///
d6min[1,1],d6max[1,1]

matrix selapopminmax = eff2min[2,1],eff2max[2,1],ros4min[2,1],ros4max[2,1], ///
d6min[2,1],d6max[2,1]

matrix ciepminmax = eff2min[1,2],eff2max[1,2],ros4min[1,2],ros4max[1,2], ///
d6min[1,2],d6max[1,2]

matrix seciepminmax = eff2min[2,2],eff2max[2,2],ros4min[2,2],ros4max[2,2], ///
d6min[2,2],d6max[2,2]

matrix minmaxdiff = eff2min_diff[1,1],eff2max_diff[1,1],ros4min_diff[1,1],ros4max_diff[1,1], ///
d6min_diff[1,1],d6max_diff[1,1]

matrix seminmaxdiff = eff2min_diff[2,1],eff2max_diff[2,1],ros4min_diff[2,1],ros4max_diff[2,1], ///
d6min_diff[2,1],d6max_diff[2,1]

/* Adding the values of the proportions and standard errors together to make table */

estadd matrix lapopminmax
estadd matrix selapopminmax
estadd matrix ciepminmax
estadd matrix seciepminmax
estadd matrix minmaxdiff
estadd matrix seminmaxdiff

* Comparing endpoint responses across modes with one-to-one matching (Table A5)

esttab using endpointappendix.rtf, ///
cells("lapopminmax(fmt(3)) ciepminmax minmaxdiff" "selapopminmax(par) seciepminmax(par) seminmaxdiff(par)") ///
collabels("LAPOP" "CIEP" "Difference") coeflabels (c1 "EFF SD" c2 "EFF SA" c3 "ROS4 SD" ///
c4 "ROS4 SA" c5 "D6 SD" c6 "D6 SA") noobs ///
addnotes(Note: Standard errors in parentheses.) nomtitles nonumbers replace


